<?php
declare (strict_types = 1);

namespace app;

use app\services\AuthorityService;
use app\services\LogService;
use app\services\MenuService;
use app\services\RoleService;
use app\services\AdminService;
use app\services\UtilService;
use app\services\WorkflowService;
use think\Service;

/**
 * 应用服务类
 */
class AppService extends Service
{
    public function register()
    {
         // 服务注册
        $iterator = scandir(app()->getAppPath().'services');
        foreach ($iterator as $item) {
            if (str_ends_with($item, 'Service.php')) {
                $name = str_replace([
                    app()->getAppPath().'services'.DIRECTORY_SEPARATOR,
                    '.php'
                ], '', $item);
                if ($name) {
                    $name = str_replace(DIRECTORY_SEPARATOR, '\\', $name);
                    $serviceBaseName = basename($item, '.php');
                    $serviceClassName = 'app\\services\\'.$name;
                    $this->app->bind(
                        lcfirst($serviceBaseName),
                        $serviceClassName
                    );
                }
            }
        }
    }

    public function boot()
    {
        // 服务启动
    }
}
